package com.hotel.mapper;

import com.hotel.pojo.Hotel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HotelMapper {
    // 查询所有酒店信息
    @Select("select * from hotel")
    List<Hotel> findAllHotel();

    // 根据酒店名称查询信息
    @Select("select * from hotel where name = #{name}")
    Hotel findHotelByName(String name);

    // 添加酒店
    @Insert("insert into hotel(name, address, phone, introduction, staff) values(#{name}, #{address}, #{phone}, #{introduction}, #{staff})")
    void addHotel(Hotel hotel);

    // 更新酒店信息
    @Update("update hotel set address=#{address}, phone=#{phone}, introduction=#{introduction}, staff=#{staff} where name=#{name}")
    void updateHotel(Hotel hotel);

    // 删除酒店
    @Delete("delete from hotel where name=#{name}")
    void deleteHotel(Hotel hotel);

    // 查看酒店负责人
    @Select("select staff from hotel where name=#{name}")
    String findStaffByHotel(String name);

    // 根据负责人查询酒店
    @Select("select * from hotel where staff=#{staff}")
    List<Hotel> findHotelByStaff(String staff);
}
